//
//  Emoticon.swift
//  EmotiDemo
//
//  Created by leador on 17/5/16.
//  Copyright © 2017年 袁满. All rights reserved.
//

import UIKit

class Emoticon: NSObject {

    var code : String? {
        
        didSet {
            
            guard let code = code else {
                return
            }
            
            let scanner = Scanner(string: code)
            
            var value : UInt32 = 0
            scanner.scanHexInt32(&value)
            
            let c = Character(UnicodeScalar(value)!)
            
            emojiCode = String(c)
            
        }
        
    }

    var chs : String?
    var png : String? {
        
        didSet {
            
            guard let png = png else {
                return
            }
            
            pngPath = Bundle.main.bundlePath + "/Emoticons.bundle/" + png
        }
        
    }
    
    var pngPath : String?
    
    var emojiCode : String?
    
    var isRemove : Bool = false
    
    var isEmpty : Bool = false
    
    init(isRemove:Bool) {
        super.init()
        self.isRemove = isRemove
    }
    
    init(isEmpty:Bool) {
        super.init()
        self.isEmpty = isEmpty
    }
    
    init(dict: [String:String]) {
        
        super.init()
        
        setValuesForKeys(dict)
        
    }
    
    override func setValue(_ value: Any?, forUndefinedKey key: String) {
    }
    
    override var description: String {
        return dictionaryWithValues(forKeys: ["emojiCode","chs","pngPath"]).description
    }
    
}
